home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c / 577 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.1 KB

  1. Path: fnnews.fnal.gov!berg
  2. From: berg@fsui01.fnal.gov (David Berg)
  3. Newsgroups: comp.lang.c,comp.std.c
  4. Subject: atexit() internals under Unix
  5. Followup-To: poster
  6. Date: 15 Mar 1996 22:18:30 GMT
  7. Organization: FERMILAB, Batavia, IL
  8. Distribution: world
  9. Message-ID: <4icqbm$pk9@fnnews.fnal.gov>
  10. NNTP-Posting-Host: fsui01.fnal.gov
  11. X-newsreader: xrn 8.01
  12.  
  13. I have a some questions regarding ANSI C in a Unix (or POSIX) context.
  14. They all relate to exit handling. I don't have a copy of the ANSI C
  15. standard, nor have I been able to find more than cursory explanations
  16. in other reference sources.
  17.  
  18. 1. Suppose a process registers an exit handler with atexit().  The exit
  19.    handler, in turn, calls some application library routines, which call
  20.    others that are also called from the mainline of the program. Leaving
  21.    the issue of re-entrancy aside, is there any general way (eg, a system
  22.    service call) by which the function can determine that it was called
  23.    in the context of an exit handler? Can it access the exit status with
  24.    which exit() was called?
  25.  
  26. 2. Same as above, except the process registers a signal handler with
  27.    sigaction(). Can a lower level function determine that it was called
  28.    in the context of a signal handler? What if the signal handler calls
  29.    exit()?
  30.  
  31. 3. Suppose the process now forks. From experimentation, it appears that
  32.    exit handlers, like signal handlers, are inherited by the child. Is
  33.    this behavior standard (though beyond the scope of ANSI), or at least
  34.    conventional?
  35.  
  36. 4. If an exit handler calls exit(), is the handler called recursively? Or
  37.    has it been unregistered before it is invoked? (Again, it would appear
  38.    from experimentation that it is indeed unregistered.)
  39.  
  40. Thanks.
  41.  
  42. ---------------------------+-----------------------------------------
  43.    "A nanosecond here,     |    David M. Berg        (berg@fnal.gov)
  44.    a nanosecond there,     |  Computing Division
  45.  and pretty soon you're    |    Fermilab MS120
  46. talking about Real Time."  |      PO Box 500        tel: 708-840-3021
  47. (apologies to the late     |   Batavia IL 60510     fax: 708-840-2783
  48.  Sen. Everett Dirksen)     |
  49.